#include "PassBallNearToGoalieBehaviour.h"

/*
 * Pouzije sa ak je brankar nebezpecne blizko a strielat nie je vhodne
 *
 */
void PassBallNearToGoalieBehaviour::Behave()
{
	Point myPosition = world->me->pos;
	Vector meGoalie = (DATA_STORAGE.GetEnemyGoalie()->pos - myPosition);
				
	if(myPosition.GetY() > 0)
		meGoalie.SetAngle(meGoalie.GetAngle() - DegAngle(70));
	else
		meGoalie.SetAngle(meGoalie.GetAngle() + DegAngle(70));

	float lfDistance = meGoalie.GetLength();
	float lfPassSpeed = (lfDistance - (float)lfMinPassDistance) / ((float)lfMaxPassDistance - (float)lfMinPassDistance) 
					* (world->params->server->ball_speed_max - 0.75f) +  0.75f;
				
	GetPassBallToBehaviour()->Behave(myPosition + meGoalie, GetPassBallToBehaviour()->CorrectPassSpeed(lfPassSpeed));
}